import featureAbility from '@ohos.ability.featureAbility';
export default {
    data: {
        title: 'World'
    },
    getWantPromise(){
        featureAbility.getWant()
            .then((Want) => {
            console.info('success data:getWant : ' + JSON.stringify(Want));
        }).catch((error) => {
            console.error('failed to getWant because ' + JSON.stringify(error));
        })
    },
    // // 下方的参数位置已被更换过 原来的写法是(err,data)=>{}
    getWantCallback(){
        featureAbility.getWant((data, err) => {
            if (err) {
                console.error('failed to getWant because ' + JSON.stringify(err));
                return;
            }
            console.info('success data:getWant : ' + JSON.stringify(data))
        })
    },
    startAbilityPromise(){
        var str = {
            "StartAbilityParameter": {
                "want": {
                    "deviceId": "GGB",
                    "bundleName": "GGB",
                    "abilityName": "GGB",
                    "uri": "",
                    "type": "phone",
                    "options": {},
                    "action": "",
                    "parameters": {},
                    "entities": [
                        "entity.com.example.mytest.ENTITIES"
                    ]
                },
                "abilityStartSetting": {}
            }
        };
        featureAbility.startAbility(str)
            .then((number) => {
            console.info('success data : ' + JSON.stringify(number))
        }).catch((error) => {
            console.error('failed to get number because ' + JSON.stringify(error));
        })
    },
    startAbilityCallback(){
        var str = {
            "StartAbilityParameter": {
                "want": {
                    "deviceId": "",
                    "bundleName": "",
                    "abilityName": "",
                    "uri": "",
                    "type": "phone",
                    "options": {},
                    "action": "",
                    "parameters": {},
                    "entities": [
                        "entity.com.example.mytest.ENTITIES"
                    ]
                },
                "abilityStartSetting": {}
            }
        };
        // 下方的参数位置已被更换过 原来的写法是(err,data)=>{}
        featureAbility.startAbility(str, (data, err) => {
            if (err) {
                console.error('failed to get number because ' + JSON.stringify(err));
                return;
            }
            console.info('success data : ' + JSON.stringify(data))
        });
    },
    getContext(){
        console.log('success')
        var context = featureAbility.getContext();

    }
}
